//CHART_REPO := http://jenkins-chartmuseum:8080
CURRENT=$(pwd)
NAME := $(FILE_NAME)
OS := $(shell uname)
IMAGE_NAME := $(Artifact_ID)
K8S_persistence_enabled := ${K8S_persistence_enabled}
K8S_persistence_subpath := ${K8S_persistence_subpath}
K8S_health_path := ${K8S_health_path}
NGINX_server_url := ${NGINX_server_url}
MONGO_DEV_URL := ${MONGO_devUrl}
MONGO_PREVIEW_URL := ${MONGO_previewUrl}
MONGO_PROD_URL := ${MONGO_prodUrl}
MONGO_BUG_URL := ${MONGO_debugUrl}
MONGO_DEMO_URL := ${MONGO_demoUrl}

NODE_server_port := ${NODE_server_port}
INTERFACE_TOOL_devUrl := ${INTERFACE_TOOL_devUrl}
INTERFACE_TOOL_previewUrl := ${INTERFACE_TOOL_previewUrl}
INTERFACE_TOOL_prodUrl := ${INTERFACE_TOOL_prodUrl}
INTERFACE_TOOL_debugUrl := ${INTERFACE_TOOL_debugUrl}
INTERFACE_TOOL_demoUrl := ${INTERFACE_TOOL_demoUrl}

CODEPLATFORM_devUrl := ${CODEPLATFORM_devUrl}
CODEPLATFORM_previewUrl := ${CODEPLATFORM_previewUrl}
CODEPLATFORM_prodUrl := ${CODEPLATFORM_prodUrl}
CODEPLATFORM_debugUrl := ${CODEPLATFORM_debugUrl}
CODEPLATFORM_demoUrl := ${CODEPLATFORM_demoUrl}

replace:
ifeq ($(OS),Linux)
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" skaffold.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/dev/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/dev/requirements.yaml
	sed -i -e "s|MONGO_URL|$(MONGO_DEV_URL)|" charts/dev/values.yaml
	sed -i -e "s|INTERFACE_TOOL_URL|$(INTERFACE_TOOL_devUrl)|" charts/dev/values.yaml
	sed -i -e "s|SSO_LOGIN_URL|$(CODEPLATFORM_devUrl)|" charts/dev/values.yaml


	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/preview/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/preview/requirements.yaml
	sed -i -e "s|MONGO_URL|$(MONGO_PREVIEW_URL)|" charts/preview/values.yaml
	sed -i -e "s|INTERFACE_TOOL_URL|$(INTERFACE_TOOL_previewUrl)|" charts/preview/values.yaml
	sed -i -e "s|SSO_LOGIN_URL|$(CODEPLATFORM_previewUrl)|" charts/preview/values.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/bug/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/bug/requirements.yaml
	sed -i -e "s|MONGO_URL|$(MONGO_BUG_URL)|" charts/bug/values.yaml
	sed -i -e "s|INTERFACE_TOOL_URL|$(INTERFACE_TOOL_debugUrl)|" charts/bug/values.yaml
	sed -i -e "s|SSO_LOGIN_URL|$(CODEPLATFORM_debugUrl)|" charts/bug/values.yaml


	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/demo/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/demo/requirements.yaml
	sed -i -e "s|MONGO_URL|$(MONGO_DEMO_URL)|" charts/demo/values.yaml
	sed -i -e "s|INTERFACE_TOOL_URL|$(INTERFACE_TOOL_demoUrl)|" charts/demo/values.yaml
	sed -i -e "s|SSO_LOGIN_URL|$(CODEPLATFORM_demoUrl)|" charts/demo/values.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/$(IMAGE_NAME)/Chart.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|MONGO_URL|$(MONGO_DEV_URL)|" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|INTERFACE_TOOL_URL|$(INTERFACE_TOOL_prodUrl)|" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|SSO_LOGIN_URL|$(CODEPLATFORM_prodUrl)|" charts/$(IMAGE_NAME)/values.yaml

	sed -i -e "s/SUBPATH_NAME/$(K8S_persistence_subpath)/" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|HEALTH_PATH|$(K8S_health_path)|" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|NODE_SERVER_PORT|$(NODE_server_port)|" charts/$(IMAGE_NAME)/values.yaml

#	sed -i -e "s|SERVER_URL|$(NGINX_server_url)|g" charts/$(IMAGE_NAME)/templates/configmap.yaml
	sed -i -e "s/P_ENABLED/$(K8S_persistence_enabled)/" charts/$(IMAGE_NAME)/values.yaml
#	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" dockerfile/dockerfile-k8s

else
	echo "platfrom $(OS) not supported to release from"
	exit -1
endif